#include <bits/stdc++.h>
using namespace std;
inline long long read(){
	long long c=1,f=0;char ch=getchar();
	while(ch<'0'||ch>'9'){
		ch=getchar();
		if(ch=='-'){
			c=-1;
		}
	}
	while(ch>='0'&&ch<='9'){
		f=f*10+ch-'0';
		ch=getchar();
	}
	return c*f;
}
struct node{
	long long l;
	long long r;
}w[2000005];
long long t,n,a[1000005],b[2000005],sum[1000005],res,maxn[1000005];
bool flag1,flag2,flag3,isok;
char ans[1000005];
bool cmp_my(node p,node q){
	return p.l<q.l;
}
int main() {
	freopen("string.in","r",stdin);
	freopen("string.out","w",stdout);
	t=read();
	while(t--){
		flag1=flag2=flag3=isok=true;
		n=read();
		for(int i=1;i<=n;i++){
			a[i]=read();
			if(a[i]!=n-i){
				flag1=false;
			}
			if(a[i]>n){
				isok=false;
			}
		}
		for(int i=0;i<n*2-1;i++){
			b[i]=read();
			if(b[i]!=0&&b[i]!=1){
				flag2=false;
			}
			if(b[i]>n){
				isok=false;
			}
		}
		if(!isok){
			printf("-1\n");
			continue;
		}
		if(flag1){
			memset(sum,0,sizeof(sum));
			memset(maxn,0,sizeof(maxn));
			for(int i=0;i<n*2-1;i++){
				w[i].l=(i-b[i]+1)/2+2;
				w[i].r=(i+b[i]-1)/2+2;
				if(b[i]==0){
					continue;
				}
				sum[(i+b[i]-1)/2]++;
				if((i-b[i]+1)/2>=0){
					sum[(i-b[i]+1)/2]--;
				}
			}
			sort(w,w+n*2-1,cmp_my);
			for(int i=0;i<n*2-1;i++){
				if(maxn[w[i].l-1]>w[i].r){
					isok=false;
					break;
				}
				maxn[w[i].l]=w[i].r;
			}
			if(!isok){
				printf("-1\n");
				continue;
			}
			res=1;
			for(int i=n-1;i>=0;i--){
				ans[i]=res+'a'-1;
				sum[i]+=sum[i+1];
				if(sum[i]==0){
					res++;
				}
			}
			cout<<ans<<endl; 
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
